{{#error_message}}<div class="cash_error cash_{{element_type}}_error">{{error_message}}</div>{{/error_message}}
{{#redirecterror}}<div class="cash_error cash_{{element_type}}_error">{{copy_redirecterror}}</div>{{/redirecterror}}
<form id="cash_{{element_type}}_form_{{element_id}}" class="cash_form {{element_type}} {{#agree_checkbox}}cm-has-checkbox{{/agree_checkbox}}" method="post" action="">
	<input type="hidden" name="session_id" value="{{session_id}}" />

        {{#collect_name}}
                <input type="email" name="address" value="" placeholder="{{placeholder_text}}" required class="cash_input" />

                    <div style="width:49%;margin-right:1%;float:left;">
                    <input type="text" name="first_name" value="" placeholder="First name" required class="cash_input">
                    </div>

                <div style="width:50%;float:left;">
                    <input type="text" name="last_name" value="" placeholder="Last name" required class="cash_input">
                </div>
            <div style="clear:both; margin-bottom: 2px;"></div>
        {{/collect_name}}

        {{^collect_name}}
            {{^collect_postal}}
                <div style="width: 66%; float: left">
                    <input type="email" name="address" value="" placeholder="{{placeholder_text}}" required class="cash_input" />
                </div>
            {{/collect_postal}}
        {{/collect_name}}

        {{#collect_postal}}
            {{^collect_name}}
            <input type="email" name="address" value="" placeholder="{{placeholder_text}}" required class="cash_input" />
            {{/collect_name}}
            <div style="width: 66%; float: left">
                <input type="text" name="postal_code" value="" placeholder="ZIP or postal code" required class="cash_input">
            </div>
        {{/collect_postal}}


<input type="hidden" name="cash_request_type" value="people" />
    <input type="hidden" name="cash_action" value="signup" />
    <input type="hidden" name="element_id" value="{{element_id}}" />
    <input type="hidden" name="list_id" value="{{email_list_id}}" />
    <input type="submit" value="{{#button_text}}{{button_text}}{{/button_text}}{{^button_text}}{{copy_signup}}{{/button_text}}" class="button" />

    <div style="clear:both;"></div>

<div class="cash_emailcollection_extras" style="display:none;">
    {{^collect_name}}
    <div class="cash_first_name" style="display:none;">
        <input type="text" name="first_name" value="" />
    </div>
    <div class="cash_last_name" style="display:none;">
        <input type="text" name="last_name" value="" />
    </div>
    {{/collect_name}}

{{^collect_postal}}
<!--        <div class="cash_last_name" style="display:none;">
            <input type="text" name="postal_code" value="" />
        </div>-->
{{/collect_postal}}

        <input type="hidden" name="additional_data" class="cm-additional-data" value='{{#geo}}{"geo":{{{geo}}}}{{/geo}}' /><div class="cash_comment" style="display:none;"><input type="text" name="comment" value='' /></div></div>
</form>
<div class="cash_notation">
	{{message_privacy}}
</div>

{{^geo}}
<script type="text/javascript">
(function() {
	'use strict';
	var cm = window.cashmusic;
	cm.events.add(cm,'ready', function(e) {
		if (cm.geo) {
			document.querySelector('#cash_{{element_type}}_form_{{element_id}} input.cm-additional-data').setAttribute('value','{"geo":'+cm.geo+'}');
		}
	});
})();
</script>
{{/geo}}

{{#agree_checkbox}}
<script type="text/javascript">
(function() {
	'use strict';
	var cm = window.cashmusic;
	cm.events.add(cm,'ready', function(e) {
		document.querySelector("#cash_{{element_type}}_form_{{element_id}} .cash_emailcollection_extras").style.display = 'block';
		var el = document.querySelector("#cash_{{element_type}}_form_{{element_id}} .cash_comment input");

		var c = document.createElement('input');
		c.type = "checkbox";
		c.name = "cm-agree-checkbox";
		c.id = "cm-agree-checkbox";

		c.addEventListener("click",function(e){
			if (c.checked) {
				el.setAttribute('value','{{agree_message}}');
			} else {
				el.setAttribute('value','');
			}
		},false);

		var label = document.createElement('label')
		label.htmlFor = "cm-agree-checkbox";
		label.appendChild(c);
		label.appendChild(document.createTextNode('{{agree_message}}'));
		label.style.display = 'inline-block';
		label.style.position = 'relative';
		label.style.textIndent = 0;

		var placeholder = document.querySelector('.cash_notation');
		var container = placeholder.parentNode;

		container.insertBefore(label,placeholder);

		cm.events.add(document.querySelector("#cash_{{element_type}}_form_{{element_id}}"),'submit', function(e) {
			if (!c.checked) {
				e.preventDefault();
				document.querySelector("label[for=cm-agree-checkbox]").setAttribute("class", "cm-required");
				return false;
			} else {
				return true;
			}
		});
	});
})();
</script>
{{/agree_checkbox}}
